home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Four corner centered.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  2.5 KB  |  83 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define BlockSize 10
  15. #define CorrectTime 6
  16.  
  17. void FourCornerCentered(GrafPtr);
  18.  
  19. /* Really, this only uses one region and one CopyBits per round.  Regions don't
  20.    have to be continuous.  On each axis, on each side of the center of the screen,
  21.    there are two parts of the region which move towards different corners. */
  22.    
  23. void FourCornerCentered(GrafPtr sourceGrafPtr)
  24. {
  25.     RgnHandle    curregion;
  26.     Rect        source;
  27.     int            cx,cy,lastx,lasty,VBlockSize;
  28.     
  29.     cx = MAIN_WINDOW_WIDTH / 2;
  30.     cy = MAIN_WINDOW_HEIGHT / 2;
  31.     VBlockSize=BlockSize*MAIN_WINDOW_HEIGHT/MAIN_WINDOW_WIDTH;
  32.  
  33.     curregion=NewRgn();
  34.     source.top=source.left=0;
  35.     source.bottom=MAIN_WINDOW_HEIGHT;
  36.     source.right=MAIN_WINDOW_WIDTH;
  37.     
  38.     lasty=lastx=0;
  39.     do
  40.     {
  41.         StartTiming();
  42.         SetEmptyRgn(curregion);
  43.         MoveTo(cx,cy);
  44.         OpenRgn();              /* much much faster than 8 regions/CopyBits */
  45.             LineTo(cx-lastx,0);
  46.             Line(-BlockSize,0);
  47.             LineTo(cx+lastx+BlockSize,MAIN_WINDOW_HEIGHT);
  48.             Line(-BlockSize,0);
  49.             LineTo(cx,cy);
  50.             
  51.             LineTo(cx+lastx,0);
  52.             Line(BlockSize,0);
  53.             LineTo(cx-lastx-BlockSize,MAIN_WINDOW_HEIGHT);
  54.             Line(BlockSize,0);
  55.             LineTo(cx,cy);
  56.             
  57.             LineTo(MAIN_WINDOW_WIDTH,cy-lasty);
  58.             Line(0,-VBlockSize);
  59.             LineTo(0,cy+lasty+VBlockSize);
  60.             Line(0,-VBlockSize);
  61.             LineTo(cx,cy);
  62.             
  63.             LineTo(MAIN_WINDOW_WIDTH,cy+lasty);
  64.             Line(0,VBlockSize);
  65.             LineTo(0,cy-lasty-VBlockSize);
  66.             Line(0,VBlockSize);
  67.             LineTo(cx,cy);
  68.         CloseRgn(curregion);
  69.  
  70.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  71.             &source, &source, 0, curregion);
  72.         lastx+=BlockSize;
  73.         lasty+=VBlockSize;
  74.         TimeCorrection(CorrectTime);
  75.     }
  76.     while (lastx<cx);
  77.  
  78.     CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  79.         &source, &source, 0, 0L);    /* in case we miss a few pixels */
  80.     
  81.     DisposeRgn(curregion);
  82. }
  83.